{% load static %}
{% load manager_user_tags %}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<title>编辑栏目</title>
<link rel="stylesheet" href="{% static '/public/css/ui.css' %}">
<link rel="stylesheet" href="{% static '/public/admin/css/layout.css' %}">
<script>var api_url="/manager/upload/imagelist?type=3&multiple=1";</script>
<script src="{% static '/public/js/jquery.js' %}"></script>
<script src="{% static '/public/js/ui.js' %}"></script>
<script src="{% static '/public/admin/js/base.js' %}"></script>
<script src="{% static '/public/js/dropzone.js' %}"></script>
<script src="{% static '/public/editor/editor.js' %}"></script>
<script>
$(function()
{
	$("#catetype").change(function()
	{
		switch ($(this).val())
		{
			case "-1":
				$("#skins,#seo").removeClass("dis");
				$("#listskin,#pagenum").addClass("dis");
				$(".inner_class").addClass("ui-hide");
				$("input[name=cateurl]").removeClass("radius-right-none");
				$("#cateurl").html("别名：");
				break;
			case "-2":
				$("#skins,#seo,#pagenum").addClass("dis");
				$(".inner_class").removeClass("ui-hide");
				$("input[name=cateurl]").addClass("radius-right-none");
				$("#cateurl").html("链接网址：");
				break;
			default:
				$("#skins,#seo,#pagenum,#listskin").removeClass("dis");
				$(".inner_class").addClass("ui-hide");
				$("input[name=cateurl]").removeClass("radius-right-none");
				$("#cateurl").html("别名：");
			break;
		}
	});
	
    {% if catetype == -1 %}
		$("#skins,#seo").removeClass("dis");
		$("#listskin,#pagenum").addClass("dis");
		$(".inner_class").addClass("ui-hide");
		$("input[name=cateurl]").removeClass("radius-right-none");
		$("#cateurl").html("别名：");
	{% elif catetype == -2 %}
		$("#skins,#seo,#pagenum").addClass("dis");
		$(".inner_class").removeClass("ui-hide");
		$("input[name=cateurl]").addClass("radius-right-none");
		$("#cateurl").html("链接网址：");
	{% else %}
		$("#skins,#seo,#pagenum,#listskin").removeClass("dis");
		$(".inner_class").addClass("ui-hide");
		$("input[name=cateurl]").removeClass("radius-right-none");
		$("#cateurl").html("别名：");
	{% endif %}
	
	$(".inner_class").change(function()
	{
		$("input[name=cateurl]").val($(this).val());
	})
})
</script>
</head>

<body>
    <div class="position">当前位置：<a href="{:url('index')}">栏目管理</a> > <a href="{{ request.get_full_path }}">编辑栏目</a></div>
    <div class="borders">
        <!---->
        <form class="ui-form" method="post">
        <div class="ui-tabs ui-tabs-white">
            <ul class="ui-tabs-nav">
                <li class="active"><a href="javascript:;">基本设置</a></li>
                <li id="seo"><a href="javascript:;">Seo设置</a></li>
                <li id="skins"><a href="javascript:;">模板设置</a></li>
            </ul>
            <div class="ui-tabs-content">
                <div class="ui-tabs-pane active">
                    <div class="ui-form-group ui-row">
                        <label class="col-left ui-col-form-label">栏目名称：</label>
                        <div class="col-right" id="catename">
                            <input type="text" name="catename" class="ui-form-ip" data-rule="栏目名称:required;" value="{{ catename }}">
                        </div>
                    </div>
                    <div class="ui-form-group ui-row">
                        <label class="col-left ui-col-form-label">栏目类型：</label>
                        <div class="col-right">
                            <select class="ui-form-ip" name="catetype" id="catetype" data-rule="栏目类型:required;">
                                <option value="">请选择栏目类型</option>
                                <option value="-1"{% if catetype == -1 %} selected{% endif %}>单页</option>
                                <option value="-2"{% if catetype == -2 %} selected{% endif %}>链接</option>
                                <option value="1"{% if catetype == 1 %} selected{% endif %}>新闻</option>
                                <option value="2"{% if catetype == 2 %} selected{% endif %}>产品</option>
                                <option value="3"{% if catetype == 3 %} selected{% endif %}>招聘</option>
                            </select>
                        </div>
                    </div>
                    <div class="ui-form-group ui-row" id="alias">
                        <label class="col-left ui-col-form-label" id="cateurl">别名：</label>
                        <div class="col-right ui-input-group">
                            <input type="text" name="cateurl" class="ui-form-ip" value="{{ cateurl|default_if_none:"" }}">
                            <select class="ui-form-ip after ui-hide inner_class" style="max-width:120px;">
                            	<option value="">内部栏目</option>
                                <option value="book">留言</option>
                                <option value="sitemap">地图</option>
                                <option value="tags">标签</option>
                                <option value="bbs">社区</option>
                                <option value="user">会员</option>
                                <option value="reg">注册</option>
                                <option value="login">登录</option>
                            </select>
                        </div>
                    </div>
                    <div class="ui-form-group ui-row" id="pagenum">
                        <label class="col-left ui-col-form-label">分页数量：</label>
                        <div class="col-right">
                            <input type="text" name="catepage" class="ui-form-ip"  value="{{ catepage }}">
                            <span class="input-tips">每页显示的数量</span>
                        </div>
                    </div>
                    <div class="ui-form-group ui-row">
                        <label class="col-left ui-col-form-label">排序：</label>
                        <div class="col-right">
                            <input type="text" name="catenum" class="ui-form-ip"  value="{{ catenum }}">
                            <span class="input-tips">数字越小越靠前</span>
                        </div>
                    </div>
                    <div class="ui-form-group ui-row">
                        <label class="col-left ui-col-form-label">属性设置：</label>
                        <div class="col-right col-right-top">
                            <label class="ui-checkbox"><input type="checkbox" name="isshow" value="1"{% if isshow == 1 %} checked{% endif %}><i></i>导航显示</label>
                            <label class="ui-checkbox"><input type="checkbox" name="isblank" value="1"{% if isblank == 1 %} checked{% endif %}><i></i>新窗口</label>
                            <label class="ui-checkbox"><input type="checkbox" name="isfilter" value="1"{% if isfilter == 1 %} checked{% endif %}><i></i>列表筛选</label>
                        </div>
                    </div>
                    <div class="ui-form-group ui-row">
                        <label class="col-left ui-col-form-label">阅读权限：</label>
                        <div class="col-right col-right-top">
                            {% user_group_edit %}
                        </div>
                    </div>
                    <!--1111-->
                </div>
                
                <div class="ui-tabs-pane">
                    <!--2222-->
                    <div class="ui-form-group ui-row">
                        <label class="col-left ui-col-form-label">优化标题：</label>
                        <div class="col-right">
                            <input type="text" name="seotitle" class="ui-form-ip" value="{{ catetitle|default_if_none:"" }}">
                        </div>
                    </div>
                    <div class="ui-form-group ui-row">
                        <label class="col-left ui-col-form-label">关键字：</label>
                        <div class="col-right">
                            <input type="text" name="seokey" class="ui-form-ip" value="{{ catekey|default_if_none:"" }}">
                        </div>
                    </div>
                    <div class="ui-form-group ui-row">
                        <label class="col-left ui-col-form-label">描述：</label>
                        <div class="col-right">
                            <textarea name="seodesc" rows="4" class="ui-form-ip ui-form-limit" data-max="255">{{ catedesc|default_if_none:"" }}</textarea>
                            <div class="ui-form-limit-text"><span>0</span>/255</div>
                        </div>
                    </div>
                    <!--2222-->
                </div>
                
                <div class="ui-tabs-pane">
                    <!--3333-->
                    <div class="ui-form-group ui-row" id="listskin">
                        <label class="col-left ui-col-form-label">列表模板：</label>
                        <div class="col-right">
                        	<div class="ui-input-group">
                            	<input type="text" name="catelist" id="catelist" class="ui-form-ip radius-right-none" value="{{ catelist }}">
                            </div>
                        </div>
                    </div>
                    <div class="ui-form-group ui-row">
                        <label class="col-left ui-col-form-label">内容模板：</label>
                        <div class="col-right">
                        	<div class="ui-input-group">
                            	<input type="text" name="cateshow" id="cateshow" class="ui-form-ip radius-right-none" value="{{ cateshow }}">
                            </div>
                        </div>
                    </div>
                    <!--3333-->
                </div>                
            </div>
        </div>
        
        <div class="ui-form-group ui-mt">
        	{% csrf_token %}
            <button type="submit" class="ui-btn ui-btn-info ui-mr-sm">保存</button>
            <button type="button" class="ui-btn ui-back">返回</button>
        </div>
        </form>
        <!---->
    </div>
<script src="{% static '/public/datepick/laydate.js' %}"></script>
<script>
$(function()
{
	lay('.datepick').each(function()
	{
		laydate.render(
		{
			elem:this,
			trigger:'click'
		});
	});
	$(".ui-editor").each(function()
	{
		var toolbar=$(this).data("toolbar");
		var id=$(this).attr("id");
		$("#"+id).editor({toolbar:toolbar,upload:'{:url("upload/index")}',url:api_url,save:'{:url("upload/outimage")}'});
	});
	$(".ui-form").form(
	{
		type:2,
		result:function(form)
		{
			$.ajax(
			{
                type:'post',
                cache:false,
                dataType:'json',
                url:'/manager/category/edit/?id={{cateid}}&fid={{followid}}',
                data:$(form).serialize(),
                error:function(e){alert(e.responseText);},
                success:function(d)
                {
                    if(d.state=='success')
                    {
                        wmcms.success(d.msg);
                        setTimeout(function(){location.href='/manager/category/index?fid={{followid}}';},1500);
                    }
                    else
                    {
                        wmcms.error(d.msg);
                    }
                }
            });
		}
	});
});
</script>
</body>
</html>